<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		
		<title>Simpla Admin | Sign In</title>
		
		<!--                       CSS                       -->
	  
		<!-- Reset Stylesheet -->
		<link rel="stylesheet" href="resources/css/reset.css" type="text/css" media="screen" />
	  
		<!-- Main Stylesheet -->
		<link rel="stylesheet" href="resources/css/style.css" type="text/css" media="screen" />
		
		<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
		<link rel="stylesheet" href="resources/css/invalid.css" type="text/css" media="screen" />	
		
		<!-- Colour Schemes
	  
		Default colour scheme is green. Uncomment prefered stylesheet to use it.
		
		<link rel="stylesheet" href="resources/css/blue.css" type="text/css" media="screen" />
		
		<link rel="stylesheet" href="resources/css/red.css" type="text/css" media="screen" />  
	 
		-->
		
		<!-- Internet Explorer Fixes Stylesheet -->
		
		<!--[if lte IE 7]>
			<link rel="stylesheet" href="resources/css/ie.css" type="text/css" media="screen" />
		<![endif]-->
		
		<!--                       Javascripts                       -->
	  
		<!-- jQuery -->
		<script type="text/javascript" src="resources/scripts/jquery-1.3.2.min.js"></script>
		
		<!-- jQuery Configuration -->
		<script type="text/javascript" src="resources/scripts/simpla.jquery.configuration.js"></script>
		
		<!-- Facebox jQuery Plugin -->
		<script type="text/javascript" src="resources/scripts/facebox.js"></script>
		
		<!-- jQuery WYSIWYG Plugin -->
		<script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script>
		
		<script type="text/javascript" scr="resources/pagejs/util.js"></script>
		<!-- Internet Explorer .png-fix -->
		
		<!--[if IE 6]>
			<script type="text/javascript" src="resources/scripts/DD_belatedPNG_0.0.7a.js"></script>
			<script type="text/javascript">
				DD_belatedPNG.fix('.png_bg, img, li');
			</script>
		<![endif]-->
		
		<script>
			function setCookie(name, value, expires, path, domain, secure) { 
				var curcookie = name + "=" + encodeURI(value) 
				+((expires) ? ";expires=" + expires.toGMTString() : "") 
				+((path) ? ";path=" + path : "") 
				+((domain) ? ";domain=" + domain : "") 
				+((secure) ? ";secure" : ""); 
				document.cookie = curcookie; 
			} 

			function getCookie(name) { 
				if(document.cookie.length > 0) { 
					start = document.cookie.indexOf(name + "="); 
					if( start != -1) { 
						start = start + name.length + 1; 
						end = document.cookie.indexOf(";",start); 
						if( end == -1) { 
							end = document.cookie.length; 
						} 
						return decodeURI(document.cookie.substring(start,end)); 
					} 
					
				} 
				return ""; 
			} 

			function loginCheck(uname, pwd) { 
				var name = $("#uname").attr("value"); 
				var pass = encodeURIComponent($("#pwd").attr("value")); 
				$.ajax({
					type: "GET",
					url: "/client/userPamLogin?uname="+name+"&pwd="+pass,
					dataType : "jsonp",
					jsonnp: "callback",
					success: doLoginCheck
				});
			} 

			function doLoginCheck(data) {
				if( data.status == "success" ) { 
					var now = new Date(); 
					now.setDate( now.getDate() + 1); 
					setCookie("uname",data.results.username,now); 
					setCookie("uid",data.results.userid,now); 
					setCookie("pwd",$("#pwd").attr("value"), now);
					window.location.href = "index.html"; 
				} 
				else {
					$("#errorMsg").show();
					$("#uname").val("");
					$("#pwd").val("");
				}
			}

			function userlogin() { 
				var login = getCookie("uname"); 
				if ( login != null && login != "" ) { 

					window.location.href = "index.html"; 
				} 
			} 

			userlogin(); 

		</script>



	</head>
  
	<body id="login">
		
		<div id="login-wrapper" class="png_bg">
			<div id="login-top">
			
				<h1>优酷无线统计</h1>
				<!-- Logo (221px width) -->
				<img id="logo" src="resources/images/logo.png" alt="优酷无线统计" />
			</div> <!-- End #logn-top -->
			
			<div id="login-content">
				
				
			<div id="errorMsg" class="notification information png_bg"  style="display:none">
				<div>
					用户名或密码不正确。
				</div>
			</div>
			
			<p>
				<label>用户名</label>
				<input id="uname" class="text-input" type="text" />
			</p>
			<div class="clear"></div>
			<p>
				<label>密码</label>
				<input id="pwd" class="text-input" type="password" />
			</p>
			<div class="clear"></div>
			<p>
				<input class="button" type="submit" onclick="loginCheck()" value="Sign In" />
			</p>
					
			</div> <!-- End #login-content -->
			
		</div> <!-- End #login-wrapper -->
		
  </body>
  </html>
